//
//  Net.h
//  SceamingTimmy
//
//  Created by Yanjie Chen on 9/19/11.
//  Copyright 2011 Yanjie Chen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sys/socket.h>
#import <netinet/in.h>
#import <fcntl.h>


@interface Address : NSObject {
	uint _address;
	ushort _port;
}

@property ( nonatomic, readwrite ) uint address;
@property ( nonatomic, readwrite ) ushort port;

- (id)initWithAddress:(uint)address port:(ushort)port;
- (id)initWithA:(unsigned char)a B:(unsigned char)b C:(unsigned char)c D:(unsigned char)d port:(ushort)port;

- (unsigned char)getA;
- (unsigned char)getB;
- (unsigned char)getC;
- (unsigned char)getD;
-(void)setA:(unsigned char)a;
-(void)setB:(unsigned char)b;
-(void)setC:(unsigned char)c;
-(void)setD:(unsigned char)d;
-(void)changePortTo:(ushort)port;

@end

@interface Socket : NSObject {
	int _socket;
}

- (BOOL)open:(ushort)port;
- (BOOL)isOpen;
- (void)close;
- (BOOL)sendTo:(const Address *)addr data:(char *)data size:(int)size;
- (int)receiveFrom:(Address *)addr data:(char *)data size:(int)size;

@end


@interface Net : NSObject {

}

@end
